<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveRecord::ConnectionAdapters::SQLiteAdapter</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveRecord::ConnectionAdapters::SQLiteAdapter</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter_rb.html">
                vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="AbstractAdapter.html">
                AbstractAdapter
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
The SQLite adapter works with both the 2.x and 3.x series of SQLite with
the sqlite-ruby drivers (available both as gems and from <a
href="http://rubyforge.org/projects/sqlite-ruby">rubyforge.org/projects/sqlite-ruby</a>/).
</p>
<p>
Options:
</p>
<ul>
<li><tt>:database</tt> &#8212; Path to the database file.

</li>
</ul>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M001248">catch_schema_changes</a>&nbsp;&nbsp;
      <a href="#M001250">default_primary_key_type</a>&nbsp;&nbsp;
      <a href="#M001243">disconnect!</a>&nbsp;&nbsp;
      <a href="#M001246">empty_insert_statement</a>&nbsp;&nbsp;
      <a href="#M001245">rename_table</a>&nbsp;&nbsp;
      <a href="#M001242">requires_reloading?</a>&nbsp;&nbsp;
      <a href="#M001244">select_rows</a>&nbsp;&nbsp;
      <a href="#M001249">sqlite_version</a>&nbsp;&nbsp;
      <a href="#M001247">table_structure</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M001243" class="method-detail">
        <a name="M001243"></a>

        <div class="method-heading">
          <a href="#M001243" class="method-signature">
          <span class="method-name">disconnect!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001243-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001243-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 87</span>
87:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">disconnect!</span>
88:         <span class="ruby-keyword kw">super</span>
89:         <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">rescue</span> <span class="ruby-keyword kw">nil</span>
90:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001246" class="method-detail">
        <a name="M001246"></a>

        <div class="method-heading">
          <a href="#M001246" class="method-signature">
          <span class="method-name">empty_insert_statement</span><span class="method-args">(table_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001246-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001246-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 251</span>
251:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">empty_insert_statement</span>(<span class="ruby-identifier">table_name</span>)
252:         <span class="ruby-node">&quot;INSERT INTO #{table_name} VALUES(NULL)&quot;</span>
253:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001245" class="method-detail">
        <a name="M001245"></a>

        <div class="method-heading">
          <a href="#M001245" class="method-signature">
          <span class="method-name">rename_table</span><span class="method-args">(name, new_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001245-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001245-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 213</span>
213:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rename_table</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">new_name</span>)
214:         <span class="ruby-identifier">execute</span> <span class="ruby-node">&quot;ALTER TABLE #{name} RENAME TO #{new_name}&quot;</span>
215:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001242" class="method-detail">
        <a name="M001242"></a>

        <div class="method-heading">
          <a href="#M001242" class="method-signature">
          <span class="method-name">requires_reloading?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001242-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001242-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 83</span>
83:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">requires_reloading?</span>
84:         <span class="ruby-keyword kw">true</span>
85:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001244" class="method-detail">
        <a name="M001244"></a>

        <div class="method-heading">
          <a href="#M001244" class="method-signature">
          <span class="method-name">select_rows</span><span class="method-args">(sql, name = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001244-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001244-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 149</span>
149:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">select_rows</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword kw">nil</span>)
150:         <span class="ruby-identifier">execute</span>(<span class="ruby-identifier">sql</span>, <span class="ruby-identifier">name</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span>
151:           (<span class="ruby-value">0</span><span class="ruby-operator">...</span>(<span class="ruby-identifier">row</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">/</span> <span class="ruby-value">2</span>)).<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">row</span>[<span class="ruby-identifier">i</span>] }
152:         <span class="ruby-keyword kw">end</span>
153:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M001248" class="method-detail">
        <a name="M001248"></a>

        <div class="method-heading">
          <a href="#M001248" class="method-signature">
          <span class="method-name">catch_schema_changes</span><span class="method-args">() {|| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001248-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001248-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 345</span>
345:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">catch_schema_changes</span>
346:           <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">yield</span>
347:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">StatementInvalid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">exception</span>
348:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exception</span>.<span class="ruby-identifier">message</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/database schema has changed/</span>
349:             <span class="ruby-identifier">reconnect!</span>
350:             <span class="ruby-keyword kw">retry</span>
351:           <span class="ruby-keyword kw">else</span>
352:             <span class="ruby-identifier">raise</span>
353:           <span class="ruby-keyword kw">end</span>
354:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001250" class="method-detail">
        <a name="M001250"></a>

        <div class="method-heading">
          <a href="#M001250" class="method-signature">
          <span class="method-name">default_primary_key_type</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001250-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001250-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 360</span>
360:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">default_primary_key_type</span>
361:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">supports_autoincrement?</span>
362:             <span class="ruby-value str">'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'</span>.<span class="ruby-identifier">freeze</span>
363:           <span class="ruby-keyword kw">else</span>
364:             <span class="ruby-value str">'INTEGER PRIMARY KEY NOT NULL'</span>.<span class="ruby-identifier">freeze</span>
365:           <span class="ruby-keyword kw">end</span>
366:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001249" class="method-detail">
        <a name="M001249"></a>

        <div class="method-heading">
          <a href="#M001249" class="method-signature">
          <span class="method-name">sqlite_version</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001249-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001249-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 356</span>
356:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sqlite_version</span>
357:           <span class="ruby-ivar">@sqlite_version</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">select_value</span>(<span class="ruby-value str">'select sqlite_version(*)'</span>)
358:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M001247" class="method-detail">
        <a name="M001247"></a>

        <div class="method-heading">
          <a href="#M001247" class="method-signature">
          <span class="method-name">table_structure</span><span class="method-args">(table_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M001247-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M001247-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb, line 268</span>
268:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">table_structure</span>(<span class="ruby-identifier">table_name</span>)
269:           <span class="ruby-identifier">returning</span> <span class="ruby-identifier">structure</span> = <span class="ruby-identifier">execute</span>(<span class="ruby-node">&quot;PRAGMA table_info(#{table_name})&quot;</span>) <span class="ruby-keyword kw">do</span>
270:             <span class="ruby-identifier">raise</span>(<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">StatementInvalid</span>, <span class="ruby-node">&quot;Could not find table '#{table_name}'&quot;</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">structure</span>.<span class="ruby-identifier">empty?</span>
271:           <span class="ruby-keyword kw">end</span>
272:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>